﻿<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>Test</title>
  <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAMqy3JVSbSwum2iZgcuufmhS_2uGwzfe8k6OJPvn9bKAJsAFbixQbaaeCnYB-QjpK_DvyaVvXPtmfUw"></script>
  <script type="text/javascript">
      google.load("earth", "1");
	  var ge=null;
      var geform = window.external;
      

      function init() {
          google.earth.createInstance('map3d', initCB, failureCB);
          
      }

      function initCB(instance) {
          ge = instance;
          ge.getWindow().setVisibility(true);
          //google.earth.addEventListener(ge.getGlobe(), 'mousemove', clickEventListener);
          //google.earth.addEventListener(ge.getGlobe(), 'mousemove', clickEventListener);
          //google.earth.addEventListener(ge.getGlobe(), 'mousemove',mouseMoveEvent);
          google.earth.addEventListener(ge.getWindow(), 'click', clickEventListener);

      }
      function clickEventListener(event) {
          
          var button = event.getButton();
          var clientX = event.getClientX();
          var clientY = event.getClientY();
          var screenX = event.getScreenX();
          var screenY = event.getScreenY();
          var latitude = event.getLatitude();
          var longitude = event.getLongitude();
          var altitude = event.getAltitude();
          var hitglobe = event.getDidHitGlobe();
          var altKey = event.getAltKey();
          var ctrlKey = event.getCtrlKey();
          var shiftKey = event.getShiftKey();
          var relatedTarget = event.getTarget();
//          var relatedTarget = new Array();
//          relatedTarget[0] = "Saab";
//          relatedTarget[1] = "Volvo";
//          relatedTarget[2] = "BMW";
          geform.mouseClicked(button, clientX, clientY, screenX, screenY, latitude, longitude, altitude, hitglobe, altKey, ctrlKey, shiftKey, relatedTarget);
          //geform.mouseClicked(button);
      }
      function mouseMoveEvent(event) {
         
      }
      function failureCB(errorCode) {
          //geform.geLoadFailed();
      }
      function addPlacemarkAtScreen(lat, lon, name) {
          // Create the placemark.
          var placemark = ge.createPlacemark('');
          placemark.setName(name);
          
          // Set the placemark's location.  
          var point = ge.createPoint('');
          point.setLatitude(lat);
          point.setLongitude(lon);
          placemark.setGeometry(point);

          // Add the placemark to Earth.
          ge.getFeatures().appendChild(placemark);
      }
      function addPlacemark(lat, lon, name, iconDir) {
          // Create the placemark.
          var placemark = ge.createPlacemark('');
          placemark.setName(name);

          // Define a custom icon.
          var icon = ge.createIcon('');
          icon.setHref(iconDir);
          var style = ge.createStyle(''); //create a new style
          style.getIconStyle().setIcon(icon); //apply the icon to the style
          placemark.setStyleSelector(style); //apply the style to the placemark

          // Set the placemark's location.  
          var point = ge.createPoint('');
          point.setLatitude(lat);
          point.setLongitude(lon);
          placemark.setGeometry(point);

          // Add the placemark to Earth.
          ge.getFeatures().appendChild(placemark);
      }
       
   </script>
  <style type="text/css">
    html, body { margin:0px }
    #map3d_container  {
      display:block;
      position:absolute;
      top:0;
      left:0;
      width:100%;
      height:100%;
    }
    #map3d { height: 100%; }
  </style>
</head>
<body onload='init();' id='body'>
<div id='map3d_container'>
  <div id='map3d'></div>
</div>
</body>
</html>